package model;

import java.util.ArrayList;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

public class EmployeeLanguage extends Model
{
	private Employee	employee;
	private Language	language;

	public EmployeeLanguage()
	{

	}

	public Employee getEmployee()
	{
		return employee;
	}

	public void setEmployee(Employee employee)
	{
		this.employee = employee;
	}

	public Language getLanguage()
	{
		return language;
	}

	public void setLanguage(Language language)
	{
		this.language = language;
	}

	public static EmployeeLanguage getEmployeeLanguage(Session session, Employee employee, Language language)
	{
		Criteria criteria = session.createCriteria(EmployeeLanguage.class);
		Criterion criterion = Restrictions.eq("employee", employee);
		Criterion criterion2 = Restrictions.eq("language", language);
		criteria.add(criterion);
		criteria.add(criterion2);
		return (EmployeeLanguage) criteria.uniqueResult();
	}

	@SuppressWarnings("unchecked")
	public static ArrayList<EmployeeLanguage> getEmployeeLanguagesByEmployee(Session session, Employee employee)
	{
		Criteria criteria = session.createCriteria(EmployeeLanguage.class);
		Criterion criterion = Restrictions.eq("employee", employee);
		criteria.add(criterion);
		return (ArrayList<EmployeeLanguage>) criteria.list();
	}
}
